﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Speech.Synthesis;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ChoJu.Single.DAL
{
    internal class WindowVoice
    {
        private SpeechSynthesizer _voice;

        public WindowVoice()
        {
            _voice = new SpeechSynthesizer();
            // 设置语音音量
            _voice.Volume = 100;

            // 设置语音语速
            _voice.Rate = 5;

            // 设置语音音调
            //_voice. = 0;
        }

        public void Send(string message)
        {
            // 创建一个Prompt用于设置要播报的文本
            PromptBuilder promptBuilder = new PromptBuilder();
            //promptBuilder.AppendText(message, PromptRate.Slow); // 使用PromptRate可以设置不同的语速
            promptBuilder.AppendText(message, PromptEmphasis.Strong);

            // 播报文本
            _voice.Speak(promptBuilder);

            //Thread.Sleep(1000 * 3);
            //promptBuilder.AppendText(message, PromptEmphasis.Reduced);
            //// 播报文本
            //_voice.Speak(promptBuilder);
        }
    }
}
